<template>
  <div>
    <custom-table
      :columns="columns"
      :query="queryParams"
      v-bind="$attrs"
      v-on="listeners"
      @tap-head-btn="onTapHeadBtn"
      @tap-row-btn="onTapRowBtn"
      @row-dblclick="onRowDbClick"
    >
    </custom-table>
  </div>

</template>

<script>
import tableMixin from '@/utils/mixin/custom-table'
import mock from '@/utils/mixin/mock'

var Mock = require('mockjs')

export default {
  data() {
    return {
      columns: [
        { name: '名称', field: 'name', width: 150, type: 'tag' },
        { name: 'IMEI', field: 'imei', width: 150 },
        { name: '状态', field: 'status', type: 'tag', opts: {} },
        { name: '添加时间', field: 'create_time', width: 150 }
      ]
    }
  },
  components: {},
  mixins: [
    tableMixin, mock
  ],
  computed: {
    rowBtn() {
      return []
    }
  },
  props: {},
  filters: {},
  created() {
  },
  methods: {
    onLoad() {
      Mock.Random.extend({
        status() {
          return this.pick(['禁用', '启用'])
        }
      })
      var data = Mock.mock({
        // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
        'list|20': [{
          // 属性 id 是一个自增数，起始值为 1，每次增 1
          'id|+1': 1,
          'name': '测温仪',
          'imei': /\d{15}/,
          'status': '@status',
          'create_time': '@now'
        }]
      })

      console.log('mock', data)

      this.setMockData(data)
    }
  }
}
</script>

<style lang="scss">

</style>
